﻿// <copyright file="SettingsForm.cs" company="QUT">
//     Copyright (c) QUT. All rights reserved.
// </copyright>
 
namespace GenerateKml
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    /// <summary>
    /// This Windows Forms class will provide the functionatlity to modify the settings contained within the application configuration file.
    /// </summary>
    public partial class SettingsForm : Form
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SettingsForm"/> class.
        /// </summary>
        public SettingsForm()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Handles the Load event of the SettingsForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            this.ShowWelcomeScreenCheckBox.Checked = Configuration.ShowWelcomeScreen;
            this.SelectALPColourButton.BackColor = Configuration.ALPColour;
            this.SelectLPColourButton.BackColor = Configuration.LPColour;
            this.SelectNPColourButton.BackColor = Configuration.NPColour;
            this.SelectDEMColourButton.BackColor = Configuration.DEMColour;
            this.SelectGRNColourButton.BackColor = Configuration.GRNColour;
            this.SelectOTHColourButton.BackColor = Configuration.OTHColour;
        }

        /// <summary>
        /// Handles the Click event of the btnSelectALPColour control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnSelectALPColour_Click(object sender, EventArgs e)
        {
            if (this.MainColorDialog.ShowDialog() == DialogResult.OK)
            {
                this.SelectALPColourButton.BackColor = this.MainColorDialog.Color;
            }
        }

        /// <summary>
        /// Handles the Click event of the btnSelectLPColour control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnSelectLPColour_Click(object sender, EventArgs e)
        {
            if (this.MainColorDialog.ShowDialog() == DialogResult.OK)
            {
                this.SelectLPColourButton.BackColor = this.MainColorDialog.Color;
            }
        }

        /// <summary>
        /// Handles the Click event of the btnSelectNPColour control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnSelectNPColour_Click(object sender, EventArgs e)
        {
            if (this.MainColorDialog.ShowDialog() == DialogResult.OK)
            {
                this.SelectNPColourButton.BackColor = this.MainColorDialog.Color;
            }
        }

        /// <summary>
        /// Handles the Click event of the btnSelectDEMColour control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnSelectDEMColour_Click(object sender, EventArgs e)
        {
            if (this.MainColorDialog.ShowDialog() == DialogResult.OK)
            {
                this.SelectDEMColourButton.BackColor = this.MainColorDialog.Color;
            }
        }

        /// <summary>
        /// Handles the Click event of the btnSelectGRNColour control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnSelectGRNColour_Click(object sender, EventArgs e)
        {
            if (this.MainColorDialog.ShowDialog() == DialogResult.OK)
            {
                this.SelectGRNColourButton.BackColor = this.MainColorDialog.Color;
            }
        }

        /// <summary>
        /// Handles the Click event of the btnSelectOTHColour control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnSelectOTHColour_Click(object sender, EventArgs e)
        {
            if (this.MainColorDialog.ShowDialog() == DialogResult.OK)
            {
                this.SelectOTHColourButton.BackColor = this.MainColorDialog.Color;
            }
        }

        /// <summary>
        /// Handles the Click event of the btnOK control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnOK_Click(object sender, EventArgs e)
        {
            Configuration.ShowWelcomeScreen = this.ShowWelcomeScreenCheckBox.Checked;
            Configuration.ALPColour = this.SelectALPColourButton.BackColor;
            Configuration.LPColour = this.SelectLPColourButton.BackColor;
            Configuration.NPColour = this.SelectNPColourButton.BackColor;
            Configuration.DEMColour = this.SelectDEMColourButton.BackColor;
            Configuration.GRNColour = this.SelectGRNColourButton.BackColor;
            Configuration.OTHColour = this.SelectOTHColourButton.BackColor;
            Configuration.Save();
            this.Close();
        }

        /// <summary>
        /// Handles the Click event of the btnCancel control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
